
 <!DOCTYPE HTML>
<html >
<head>
  <meta charset="UTF-8">
  
    <title>dubbo泛化实现与引用 | Typhoon&#39;s code space</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">
    
    <meta name="author" content="typhoon">
    

    
    <meta name="description" content="现在分布式架构盛行，RPC框架也被大家熟知，目前就国内而言，dubbo可以说是中小型企业的首选。我们先看一下官网上的一张图：">
<meta property="og:type" content="article">
<meta property="og:title" content="dubbo泛化实现与引用">
<meta property="og:url" content="http://scorpioaeolus.oschina.io/2018/05/20/dubbo泛化实现与引用/index.html">
<meta property="og:site_name" content="Typhoon&#39;s code space">
<meta property="og:description" content="现在分布式架构盛行，RPC框架也被大家熟知，目前就国内而言，dubbo可以说是中小型企业的首选。我们先看一下官网上的一张图：">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2018/05/20/dubbo泛化实现与引用/dubbo-architecture.jpg">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2018/05/20/dubbo泛化实现与引用/g.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2018/05/20/dubbo泛化实现与引用/generic.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2018/05/20/dubbo泛化实现与引用/server.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2018/05/20/dubbo泛化实现与引用/consumer.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2018/05/20/dubbo泛化实现与引用/test.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2018/05/20/dubbo泛化实现与引用/api.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2018/05/20/dubbo泛化实现与引用/test2.png">
<meta property="og:image" content="http://scorpioaeolus.oschina.io/typhoon/2018/05/20/dubbo泛化实现与引用/h4.jpg">
<meta property="og:updated_time" content="2018-05-20T06:21:10.537Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="dubbo泛化实现与引用">
<meta name="twitter:description" content="现在分布式架构盛行，RPC框架也被大家熟知，目前就国内而言，dubbo可以说是中小型企业的首选。我们先看一下官网上的一张图：">
<meta name="twitter:image" content="http://scorpioaeolus.oschina.io/typhoon/2018/05/20/dubbo泛化实现与引用/dubbo-architecture.jpg">

    
    <link rel="alternative" href="/atom.xml" title="Typhoon&#39;s code space" type="application/atom+xml">
    
    
    <link rel="icon" href="/typhoon/img/java.png">
    
    
    <link rel="apple-touch-icon" href="/typhoon/img/jacman.jpg">
    <link rel="apple-touch-icon-precomposed" href="/typhoon/img/jacman.jpg">
    
    <link rel="stylesheet" href="/typhoon/css/style.css">
</head>

  <body>
    <header>
      
<div>
		
			<div id="imglogo">
				<a href="/typhoon/"><img src="/typhoon/img/java.png" alt="Typhoon&#39;s code space" title="Typhoon&#39;s code space"/></a>
			</div>
			
			<div id="textlogo">
				<h1 class="site-name"><a href="/typhoon/" title="Typhoon&#39;s code space">Typhoon&#39;s code space</a></h1>
				<h2 class="blog-motto"></h2>
			</div>
			<div class="navbar"><a class="navbutton navmobile" href="#" title="Menu">
			</a></div>
			<nav class="animated">
				<ul>
					<ul>
					 
						<li><a href="/typhoon/">主页</a></li>
					
						<li><a href="/typhoon/archives">归档</a></li>
					
						<li><a href="/typhoon/about">关于</a></li>
					
					<li>
 					
					<form class="search" action="//google.com/search" method="get" accept-charset="utf-8">
						<label>Search</label>
						<input type="search" id="search" name="q" autocomplete="off" maxlength="20" placeholder="Search" />
						<input type="hidden" name="q" value="site:scorpioaeolus.oschina.io">
					</form>
					
					</li>
				</ul>
			</nav>			
</div>
    </header>
    <div id="container">
      <div id="main" class="post" itemscope itemprop="blogPost">
  
	<article itemprop="articleBody"> 
		<header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/typhoon/2018/05/20/dubbo泛化实现与引用/" title="dubbo泛化实现与引用" itemprop="url">dubbo泛化实现与引用</a>
  </h1>
  <p class="article-author">By
       
		<a href="/typhoon/about" title="typhoon" target="_blank" itemprop="author">typhoon</a>
		
  <p class="article-time">
    <time datetime="2018-05-20T04:40:49.000Z" itemprop="datePublished"> Published 2018-05-20</time>
    
  </p>
</header>
	<div class="article-content">
		
		<div id="toc" class="toc-article">
			<strong class="toc-title">Contents</strong>
		
			<ol class="toc"><li class="toc-item toc-level-6"><a class="toc-link" href="#何谓泛化引用？"><span class="toc-number">1.</span> <span class="toc-text">何谓泛化引用？</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#I-服务端编写与启动"><span class="toc-number">2.</span> <span class="toc-text">I 服务端编写与启动</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#I-消费端编写与测试"><span class="toc-number">3.</span> <span class="toc-text">I 消费端编写与测试</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#泛化引用应用场景"><span class="toc-number">4.</span> <span class="toc-text">泛化引用应用场景</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#泛化实现"><span class="toc-number">5.</span> <span class="toc-text">泛化实现</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#附上本人公众号"><span class="toc-number">6.</span> <span class="toc-text">附上本人公众号</span></a></li></ol>
		
		</div>
		
		<pre><code>现在分布式架构盛行，RPC框架也被大家熟知，目前就国内而言，dubbo可以说是中小型企业的首选。我们先看一下官网上的一张图：
</code></pre><a id="more"></a>
<img src="/typhoon/2018/05/20/dubbo泛化实现与引用/dubbo-architecture.jpg" alt="dubbo" title="dubbo">
<pre><code>这张图从架构的角度展现了，dubbo框架的关键组件和实现方式。那么我们在日常开发中的使用方式大概如下图：
</code></pre><img src="/typhoon/2018/05/20/dubbo泛化实现与引用/g.png" alt="dubbo" title="dubbo">
<pre><code>    也就是说服务提供者，有一个interface(也叫client)，还有一个服务实现，interface给消费者依赖。这样做没问题，
我们分析一下，这种方式有优点也会优缺点：
优点:1）消费端像调用本地服务一样调用远程服务，使用简单
缺点:1）服务端interface会带过来一些依赖可能和消费端某些依赖冲突  2）服务端interface也许会把自己的配置传递到消费端，导致
        消费端平白无故要多配置完全和自己无关或者不关心的项

    假如我有一下这些场景：
1）消费端只依赖了服务端一个服务(或者说很少)
2）消费端不想把interface的依赖带过来，导致需要花费人力成本去排包，让依赖变得特别重
3）消费端只依赖服务，只关心它所以来的服务调用方式和返回结果，完全不关心你服务怎么实现的，你依赖什么配置，你把这些配置传递给我，
   我是无法接受的

   基于上述问题和描述的应用场景，dubbo提供了泛化引用。
</code></pre><h6 id="何谓泛化引用？"><a href="#何谓泛化引用？" class="headerlink" title="何谓泛化引用？"></a>何谓泛化引用？</h6><pre><code>   官网给了如下解释：
泛化接口调用方式主要用于客户端没有 API 接口及模型类元的情况，参数及返回值中的所有 POJO 均用 Map 表示，
通常用于框架集成，比如：实现一个通用的服务测试框架，可通过 GenericService 调用所有服务实现。

   我自己的理解是，不直接依赖服务提供者，利用dubbo框架层的特性来实现远程服务调用：
</code></pre><img src="/typhoon/2018/05/20/dubbo泛化实现与引用/generic.png" alt="dubbo" title="dubbo">
<pre><code>接下来就一步一步实现dubbo服务的泛型引用。
</code></pre><h6 id="I-服务端编写与启动"><a href="#I-服务端编写与启动" class="headerlink" title="I 服务端编写与启动"></a>I 服务端编写与启动</h6><pre><code>服务端结构如下图：
</code></pre><img src="/typhoon/2018/05/20/dubbo泛化实现与引用/server.png" alt="dubbo" title="dubbo">
<pre><code>具体实现参考
</code></pre><blockquote><footer><strong>徒手搭建dubbo</strong><cite><a href="http://scorpioaeolus.oschina.io/typhoon/2017/12/21/%E5%BE%92%E6%89%8B%E6%90%AD%E5%BB%BAdubbo%E6%9C%8D%E5%8A%A1/">scorpioaeolus.oschina.io/typhoon/2017/12/21/%E5%BE%92%E6%89%8B%E6%90%AD%E5%BB%BAdubbo%E6%9C%8D%E5%8A%A1</a></cite></footer></blockquote>
<h6 id="I-消费端编写与测试"><a href="#I-消费端编写与测试" class="headerlink" title="I 消费端编写与测试"></a>I 消费端编写与测试</h6><pre><code>消费端工程如下图:
</code></pre><img src="/typhoon/2018/05/20/dubbo泛化实现与引用/consumer.png" alt="dubbo" title="dubbo">
<pre><code>1)dubbo-consumer-interface层定义service和响应
service:
</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">public interface ImitateConsumerService &#123;</div><div class="line">	</div><div class="line">	/**</div><div class="line">	 * 客户端查询用户信息</div><div class="line">	 * </div><div class="line">	 * @param id</div><div class="line">	 * @return</div><div class="line">	 */</div><div class="line">	ResponseBase doQueryUserById(Long id);</div><div class="line"></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<pre><code>response:
</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div></pre></td><td class="code"><pre><div class="line">/**</div><div class="line"> * 响应</div><div class="line"> * </div><div class="line"> * @author Typhoon</div><div class="line"> *</div><div class="line"> */</div><div class="line">public class ResponseBase implements Serializable &#123;</div><div class="line">	</div><div class="line">	private static final long serialVersionUID = 7825036327382479394L;</div><div class="line">	</div><div class="line">	public static final String SUCCESS = &quot;4001&quot;;</div><div class="line">	</div><div class="line">	public static final String ERROR_CODE = &quot;4000&quot;;</div><div class="line">	</div><div class="line">	private String code = &quot;4001&quot;;</div><div class="line">	</div><div class="line">	private String reason;</div><div class="line">	</div><div class="line">	private String result;</div><div class="line">	</div><div class="line">	private Object content;</div><div class="line"></div><div class="line">	······</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<pre><code>2)dubbo-consumer-provider编写服务引用与测试
    consumer只依赖基本的dubbo和spring。dubbo泛化引用有两种实现方式:
①通过 Spring 使用泛化调用
</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">&lt;dubbo:reference interface=&quot;com.typhoon.service.UserService&quot;  url=&quot;dubbo://localhost:20289&quot; id=&quot;userService&quot; protocol=&quot;dubbo&quot; timeout=&quot;30000&quot; generic=&quot;true&quot; /&gt;</div></pre></td></tr></table></figure>
<pre><code>服务引用具体实现
</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div></pre></td><td class="code"><pre><div class="line">@Service(&quot;imitateConsumerService&quot;)</div><div class="line">public class ImitateConsumerServiceImpl implements ImitateConsumerService,ApplicationContextAware &#123;</div><div class="line">	private GenericService genericService ;</div><div class="line">	@Override</div><div class="line">	public ResponseBase doQueryUserById(Long id) &#123;</div><div class="line">		ResponseBase resp = new ResponseBase();</div><div class="line">		String methodName = &quot;queryByPK&quot;;</div><div class="line">		String[] paramTypes = new String[1];</div><div class="line">		paramTypes[0] = &quot;java.lang.Long&quot;;</div><div class="line">		Object[] params = new Object[1];</div><div class="line">		params[0] = id;</div><div class="line">		Object result = this.genericService.$invoke(methodName,paramTypes,params);</div><div class="line">		resp.setAttach(result);</div><div class="line">		return resp;</div><div class="line">	&#125;</div><div class="line"></div><div class="line">	@Override</div><div class="line">	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException &#123;</div><div class="line">		if(null == applicationContext) &#123;</div><div class="line">			throw new IllegalArgumentException(&quot;applicationContext未注入&quot;);</div><div class="line">		&#125;</div><div class="line">		this.genericService = (GenericService)applicationContext.getBean(&quot;userService&quot;);</div><div class="line">	&#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<pre><code>将dubbo-server端启动，在消费端编写单元测试
</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line">@RunWith(SpringJUnit4ClassRunner.class)</div><div class="line">@ContextConfiguration(&#123;&quot;classpath:spring-root.xml&quot;&#125;)</div><div class="line">public class Test1 &#123;</div><div class="line">	</div><div class="line">	@Resource</div><div class="line">	ImitateConsumerService imitateConsumerService;</div><div class="line"></div><div class="line">	@Test</div><div class="line">	public void testA() &#123;</div><div class="line">		try &#123;</div><div class="line">			ResponseBase resp = this.imitateConsumerService.doQueryUserById(1L);</div><div class="line">			System.out.println(JSON.toJSONString(resp));</div><div class="line">		&#125; catch (Exception e) &#123;</div><div class="line">			e.printStackTrace();</div><div class="line">		&#125;</div><div class="line">	&#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<pre><code>运行单元测试
</code></pre><img src="/typhoon/2018/05/20/dubbo泛化实现与引用/test.png" alt="dubbo" title="dubbo">
<pre><code>②通过 API 方式使用泛化调用
改造①中ImitateConsumerServiceImpl的setApplicationContext方法：
</code></pre><img src="/typhoon/2018/05/20/dubbo泛化实现与引用/api.png" alt="dubbo" title="dubbo">
<pre><code>再次运行①中的单元测试，结果如下：
</code></pre><img src="/typhoon/2018/05/20/dubbo泛化实现与引用/test2.png" alt="dubbo" title="dubbo">
<pre><code>可以看到两种方式都实现了泛型引用调用rpc服务的效果。
</code></pre><h6 id="泛化引用应用场景"><a href="#泛化引用应用场景" class="headerlink" title="泛化引用应用场景"></a>泛化引用应用场景</h6><pre><code>1）服务端暴露client层比较重，富客户端或者带过来很多配置和依赖
2）消费端对服务端依赖比较轻，依赖单个或很少个服务，不想承担引入服务端接口带来的成本开销
3）只关心服务，完全不关心服务端实现
</code></pre><h6 id="泛化实现"><a href="#泛化实现" class="headerlink" title="泛化实现"></a>泛化实现</h6><pre><code>    本篇幅重点讲述了dubbo泛化引用，但是还有泛化实现的概念，泛化实现在真是项目场景中应用不是太多，反正我是尚未见过。此处简单过一下。

 官网解释：  
    泛接口实现方式主要用于服务器端没有API接口及模型类元的情况，参数及返回值中的所有POJO均用Map表示，
通常用于框架集成，比如：实现一个通用的远程服务Mock框架，可通过实现GenericService接口处理所有服务请求。

在 Java 代码中实现 GenericService 接口：
</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">package com.foo;</div><div class="line">public class MyGenericService implements GenericService &#123;</div><div class="line"></div><div class="line">    public Object $invoke(String methodName, String[] parameterTypes, Object[] args) throws GenericException &#123;</div><div class="line">        if (&quot;sayHello&quot;.equals(methodName)) &#123;</div><div class="line">            return &quot;Welcome &quot; + args[0];</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<pre><code>同样，泛化实现也有两种实现方式：
1）通过 Spring 暴露泛化实现
    在 Spring 配置申明服务的实现：
</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">&lt;bean id=&quot;genericService&quot; class=&quot;com.foo.MyGenericService&quot; /&gt;</div><div class="line">&lt;dubbo:service interface=&quot;com.foo.BarService&quot; ref=&quot;genericService&quot; /&gt;</div></pre></td></tr></table></figure>
<pre><code>3）通过 API 方式暴露泛化实现
</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line">... </div><div class="line">// 用com.alibaba.dubbo.rpc.service.GenericService可以替代所有接口实现 </div><div class="line">GenericService xxxService = new XxxGenericService(); </div><div class="line"></div><div class="line">// 该实例很重量，里面封装了所有与注册中心及服务提供方连接，请缓存 </div><div class="line">ServiceConfig&lt;GenericService&gt; service = new ServiceConfig&lt;GenericService&gt;();</div><div class="line">// 弱类型接口名 </div><div class="line">service.setInterface(&quot;com.xxx.XxxService&quot;);  </div><div class="line">service.setVersion(&quot;1.0.0&quot;); </div><div class="line">// 指向一个通用服务实现 </div><div class="line">service.setRef(xxxService); </div><div class="line"></div><div class="line">// 暴露及注册服务 </div><div class="line">service.export();</div></pre></td></tr></table></figure>
<pre><code>此篇我们根据真实业务场景讲解了dubbo泛化引用和泛化实现，希望给大家在日常开发中带来帮助！
</code></pre><p><strong><em>PS:原创不易,多多支持!</em></strong></p>
<h6 id="附上本人公众号"><a href="#附上本人公众号" class="headerlink" title="附上本人公众号"></a>附上本人公众号</h6><img src="/typhoon/2018/05/20/dubbo泛化实现与引用/h4.jpg" alt="dubbo" title="dubbo">
  
	</div>
		<footer class="article-footer clearfix">
<div class="article-catetags">

<div class="article-categories">
  <span></span>
  <a class="article-category-link" href="/typhoon/categories/dubbo/">dubbo</a>
</div>


</div>



	<div class="article-share" id="share">
	
	  <div data-url="http://scorpioaeolus.oschina.io/2018/05/20/dubbo泛化实现与引用/" data-title="dubbo泛化实现与引用 | Typhoon&#39;s code space" data-tsina="null" class="share clearfix">
	  </div>
	
	</div>


</footer>

   	       
	</article>
	
<nav class="article-nav clearfix">
 
 <div class="prev" >
 <a href="/typhoon/2018/05/20/dubbo富客户端/" title="dubbo富客户端">
  <strong>上一篇：</strong><br/>
  <span>
  dubbo富客户端</span>
</a>
</div>


<div class="next">
<a href="/typhoon/2018/04/21/代理模式/"  title="设计模式----代理模式详解">
 <strong>下一篇：</strong><br/> 
 <span>设计模式----代理模式详解
</span>
</a>
</div>

</nav>

	


</div>  
      <div class="openaside"><a class="navbutton" href="#" title="Show Sidebar"></a></div>

  <div id="toc" class="toc-aside">
  <strong class="toc-title">Contents</strong>
 
 <ol class="toc"><li class="toc-item toc-level-6"><a class="toc-link" href="#何谓泛化引用？"><span class="toc-number">1.</span> <span class="toc-text">何谓泛化引用？</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#I-服务端编写与启动"><span class="toc-number">2.</span> <span class="toc-text">I 服务端编写与启动</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#I-消费端编写与测试"><span class="toc-number">3.</span> <span class="toc-text">I 消费端编写与测试</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#泛化引用应用场景"><span class="toc-number">4.</span> <span class="toc-text">泛化引用应用场景</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#泛化实现"><span class="toc-number">5.</span> <span class="toc-text">泛化实现</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#附上本人公众号"><span class="toc-number">6.</span> <span class="toc-text">附上本人公众号</span></a></li></ol>
 
  </div>

<div id="asidepart">
<div class="closeaside"><a class="closebutton" href="#" title="Hide Sidebar"></a></div>
<aside class="clearfix">

  


  
<div class="categorieslist">
	<p class="asidetitle">Categories</p>
		<ul>
		
		  
			<li><a href="/typhoon/categories/dubbo/" title="dubbo">dubbo<sup>8</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/java性能优化/" title="java性能优化">java性能优化<sup>17</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/java源码分析/" title="java源码分析">java源码分析<sup>1</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/motan/" title="motan">motan<sup>2</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/spring/" title="spring">spring<sup>11</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/springboot/" title="springboot">springboot<sup>28</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/springmvc/" title="springmvc">springmvc<sup>1</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/容器/" title="容器">容器<sup>1</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/工具/" title="工具">工具<sup>7</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/性能优化/" title="性能优化">性能优化<sup>5</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/架构/" title="架构">架构<sup>8</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/案例分析/" title="案例分析">案例分析<sup>13</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/缓存/" title="缓存">缓存<sup>4</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/设计模式/" title="设计模式">设计模式<sup>3</sup></a></li>
		  
		
		  
			<li><a href="/typhoon/categories/面试题/" title="面试题">面试题<sup>1</sup></a></li>
		  
		
		</ul>
</div>


  
<div class="tagslist">
	<p class="asidetitle">Tags</p>
		<ul class="clearfix">
		
			
				<li><a href="/typhoon/tags/springboot/" title="springboot">springboot<sup>28</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/java性能优化/" title="java性能优化">java性能优化<sup>9</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/限流/" title="限流">限流<sup>3</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/Spring5/" title="Spring5">Spring5<sup>3</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/设计模式/" title="设计模式">设计模式<sup>3</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/案例分析/" title="案例分析">案例分析<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/性能优化/" title="性能优化">性能优化<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/Spring/" title="Spring">Spring<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/dubbo/" title="dubbo">dubbo<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/分页/" title="分页">分页<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/并发/" title="并发">并发<sup>2</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/异常拦截/" title="异常拦截">异常拦截<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/dubbo分布式事务/" title="dubbo分布式事务">dubbo分布式事务<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/自带图片/" title="自带图片">自带图片<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/svn导出mvn项目/" title="svn导出mvn项目">svn导出mvn项目<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/dubbo过滤器/" title="dubbo过滤器">dubbo过滤器<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/排序性能对比/" title="排序性能对比">排序性能对比<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/ListenableFuture/" title="ListenableFuture">ListenableFuture<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/PropertyChangeListener/" title="PropertyChangeListener">PropertyChangeListener<sup>1</sup></a></li>
			
		
			
				<li><a href="/typhoon/tags/jdbcTemplate高可用/" title="jdbcTemplate高可用">jdbcTemplate高可用<sup>1</sup></a></li>
			
		
		</ul>
</div>


  <div class="linkslist">
  <p class="asidetitle">Links</p>
    <ul>
        
          <li>
            
            	<a href="https://coderq.com" target="_blank" title="一个面向程序员交流分享的新一代社区">码农圈</a>
            
          </li>
        
          <li>
            
            	<a href="http://wuchong.me" target="_blank" title="Jark&#39;s Blog">Jark&#39;s Blog</a>
            
          </li>
        
    </ul>
</div>

  


  <div class="rsspart">
	<a href="/atom.xml" target="_blank" title="rss">RSS</a>
</div>

  <div class="weiboshow">
  <p class="asidetitle">Weibo</p>
    <iframe width="100%" height="119" class="share_self"  frameborder="0" scrolling="no" src="http://widget.weibo.com/weiboshow/index.php?language=&width=0&height=119&fansRow=2&ptype=1&speed=0&skin=9&isTitle=1&noborder=1&isWeibo=0&isFans=0&uid=null&verifier=b3593ceb&dpc=1"></iframe>
</div>


</aside>
</div>
    </div>
    <footer><div id="footer" >
	
	<div class="line">
		<span></span>
		<div class="author"></div>
	</div>
	
	
	<section class="info">
		<p> Hello ,I&#39;m a java coder. <br/>
			This is my blog,believe it or not.</p>
	</section>
	 
	<div class="social-font" class="clearfix">
		
		
		
		
		
		
		
		
		
		
		<a href="mailto:ScorpioAeolus@163.com" target="_blank" class="icon-email" title="Email Me"></a>
		
	</div>
			
		

		<p class="copyright">
		Powered by <a href="http://hexo.io" target="_blank" title="hexo">hexo</a> and Theme by <a href="https://github.com/wuchong/jacman" target="_blank" title="Jacman">Jacman</a> © 2019 
		
		<a href="/typhoon/about" target="_blank" title="typhoon">typhoon</a>
		
		
		</p>
</div>
</footer>
    <script src="/typhoon/js/jquery-2.0.3.min.js"></script>
<script src="/typhoon/js/jquery.imagesloaded.min.js"></script>
<script src="/typhoon/js/gallery.js"></script>
<script src="/typhoon/js/jquery.qrcode-0.12.0.min.js"></script>

<script type="text/javascript">
$(document).ready(function(){ 
  $('.navbar').click(function(){
    $('header nav').toggleClass('shownav');
  });
  var myWidth = 0;
  function getSize(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
  };
  var m = $('#main'),
      a = $('#asidepart'),
      c = $('.closeaside'),
      o = $('.openaside');
  c.click(function(){
    a.addClass('fadeOut').css('display', 'none');
    o.css('display', 'block').addClass('fadeIn');
    m.addClass('moveMain');
  });
  o.click(function(){
    o.css('display', 'none').removeClass('beforeFadeIn');
    a.css('display', 'block').removeClass('fadeOut').addClass('fadeIn');      
    m.removeClass('moveMain');
  });
  $(window).scroll(function(){
    o.css("top",Math.max(80,260-$(this).scrollTop()));
  });
  
  $(window).resize(function(){
    getSize(); 
    if (myWidth >= 1024) {
      $('header nav').removeClass('shownav');
    }else{
      m.removeClass('moveMain');
      a.css('display', 'block').removeClass('fadeOut');
      o.css('display', 'none');
      
      $('#toc.toc-aside').css('display', 'none');
        
    }
  });
});
</script>

<script type="text/javascript">
$(document).ready(function(){ 
  var ai = $('.article-content>iframe'),
      ae = $('.article-content>embed'),
      t  = $('#toc'),
      ta = $('#toc.toc-aside'),
      o  = $('.openaside'),
      c  = $('.closeaside');
  if(ai.length>0){
    ai.wrap('<div class="video-container" />');
  };
  if(ae.length>0){
   ae.wrap('<div class="video-container" />');
  };
  c.click(function(){
    ta.css('display', 'block').addClass('fadeIn');
  });
  o.click(function(){
    ta.css('display', 'none');
  });
  $(window).scroll(function(){
    ta.css("top",Math.max(140,320-$(this).scrollTop()));
  });
});
</script>


<script type="text/javascript">
$(document).ready(function(){ 
  var $this = $('.share'),
      url = $this.attr('data-url'),
      encodedUrl = encodeURIComponent(url),
      title = $this.attr('data-title'),
      tsina = $this.attr('data-tsina'),
      description = $this.attr('description');
  var html = [
  '<div class="hoverqrcode clearfix"></div>',
  '<a class="overlay" id="qrcode"></a>',
  '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="article-share-facebook" target="_blank" title="Facebook"></a>',
  '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="article-share-twitter" target="_blank" title="Twitter"></a>',
  '<a href="#qrcode" class="article-share-qrcode" title="微信"></a>',
  '<a href="http://widget.renren.com/dialog/share?resourceUrl=' + encodedUrl + '&srcUrl=' + encodedUrl + '&title=' + title +'" class="article-share-renren" target="_blank" title="人人"></a>',
  '<a href="http://service.weibo.com/share/share.php?title='+title+'&url='+encodedUrl +'&ralateUid='+ tsina +'&searchPic=true&style=number' +'" class="article-share-weibo" target="_blank" title="微博"></a>',
  '<span title="Share to"></span>'
  ].join('');
  $this.append(html);

  $('.hoverqrcode').hide();

  var myWidth = 0;
  function updatehoverqrcode(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
    var qrsize = myWidth > 1024 ? 200:100;
    var options = {render: 'image', size: qrsize, fill: '#2ca6cb', text: url, radius: 0.5, quiet: 1};
    var p = $('.article-share-qrcode').position();
    $('.hoverqrcode').empty().css('width', qrsize).css('height', qrsize)
                          .css('left', p.left-qrsize/2+20).css('top', p.top-qrsize-10)
                          .qrcode(options);
  };
  $(window).resize(function(){
    $('.hoverqrcode').hide();
  });
  $('.article-share-qrcode').click(function(){
    updatehoverqrcode();
    $('.hoverqrcode').toggle();
  });
  $('.article-share-qrcode').hover(function(){}, function(){
      $('.hoverqrcode').hide();
  });
});   
</script>









<link rel="stylesheet" href="/typhoon/fancybox/jquery.fancybox.css" media="screen" type="text/css">
<script src="/typhoon/fancybox/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
  $('.article-content').each(function(i){
    $(this).find('img').each(function(){
      if ($(this).parent().hasClass('fancybox')) return;
      var alt = this.alt;
      if (alt) $(this).after('<span class="caption">' + alt + '</span>');
      $(this).wrap('<a href="' + this.src + '" title="' + alt + '" class="fancybox"></a>');
    });
    $(this).find('.fancybox').each(function(){
      $(this).attr('rel', 'article' + i);
    });
  });
  if($.fancybox){
    $('.fancybox').fancybox();
  }
}); 
</script>



<!-- Analytics Begin -->



<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?e6d1f421bbc9962127a50488f9ed37d1";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>



<!-- Analytics End -->

<!-- Totop Begin -->

	<div id="totop">
	<a title="Back to Top"><img src="/typhoon/img/scrollup.png"/></a>
	</div>
	<script src="/typhoon/js/totop.js"></script>

<!-- Totop End -->

<!-- MathJax Begin -->
<!-- mathjax config similar to math.stackexchange -->


<!-- MathJax End -->

<!-- Tiny_search Begin -->

<!-- Tiny_search End -->

  </body>
</html>
